<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>dialog.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-dialogs-standarddialogs-example.html">Standard Dialogs Example</a></td><td >dialog.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">dialog.cpp 示例文件</h1>
<span class="subtitle">dialogs/standarddialogs/dialog.cpp</span>
<!-- $$$dialogs/standarddialogs/dialog.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="preprocessor">#include &quot;dialog.h&quot;</span>

  <span class="preprocessor">#define MESSAGE \
      Dialog::tr(&quot;&lt;p&gt;Message boxes have a caption, a text, &quot; \
                 &quot;and any number of buttons, each with standard or custom texts.&quot; \
                 &quot;&lt;p&gt;Click a button to close the message box. Pressing the Esc button &quot; \
                 &quot;will activate the detected escape button (if any).&quot;)</span>
  <span class="preprocessor">#define MESSAGE_DETAILS \
      Dialog::tr(&quot;If a message box has detailed text, the user can reveal it &quot; \
                 &quot;by pressing the Show Details... button.&quot;)</span>

  <span class="keyword">class</span> DialogOptionsWidget : <span class="keyword">public</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>
  {
  <span class="keyword">public</span>:
      <span class="keyword">explicit</span> DialogOptionsWidget(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

      <span class="type">void</span> addCheckBox(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>text<span class="operator">,</span> <span class="type">int</span> value);
      <span class="type">void</span> addSpacer();
      <span class="type">int</span> value() <span class="keyword">const</span>;

  <span class="keyword">private</span>:
      <span class="keyword">typedef</span> <span class="type"><a href="../qtcore/qpair.html">QPair</a></span><span class="operator">&lt;</span><span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> CheckBoxEntry;
      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>layout;
      <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>CheckBoxEntry<span class="operator">&gt;</span> checkBoxEntries;
  };

  DialogOptionsWidget<span class="operator">::</span>DialogOptionsWidget(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent) :
      <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(parent) <span class="operator">,</span> layout(<span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>)
  {
      setTitle(Dialog<span class="operator">::</span>tr(<span class="string">&quot;Options&quot;</span>));
      setLayout(layout);
  }

  <span class="type">void</span> DialogOptionsWidget<span class="operator">::</span>addCheckBox(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>text<span class="operator">,</span> <span class="type">int</span> value)
  {
      <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>checkBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(text);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(checkBox);
      checkBoxEntries<span class="operator">.</span>append(CheckBoxEntry(checkBox<span class="operator">,</span> value));
  }

  <span class="type">void</span> DialogOptionsWidget<span class="operator">::</span>addSpacer()
  {
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding));
  }

  <span class="type">int</span> DialogOptionsWidget<span class="operator">::</span>value() <span class="keyword">const</span>
  {
      <span class="type">int</span> result <span class="operator">=</span> <span class="number">0</span>;
      foreach (<span class="keyword">const</span> CheckBoxEntry <span class="operator">&amp;</span>checkboxEntry<span class="operator">,</span> checkBoxEntries)
          <span class="keyword">if</span> (checkboxEntry<span class="operator">.</span>first<span class="operator">-</span><span class="operator">&gt;</span>isChecked())
              result <span class="operator">|</span><span class="operator">=</span> checkboxEntry<span class="operator">.</span>second;
      <span class="keyword">return</span> result;
  }

  Dialog<span class="operator">::</span>Dialog(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent)
  {
      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>verticalLayout;
      <span class="keyword">if</span> (<span class="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span><span class="operator">::</span>styleHints()<span class="operator">-</span><span class="operator">&gt;</span>showIsFullScreen() <span class="operator">|</span><span class="operator">|</span> <span class="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span><span class="operator">::</span>styleHints()<span class="operator">-</span><span class="operator">&gt;</span>showIsMaximized()) {
          <span class="type"><a href="qhboxlayout.html">QHBoxLayout</a></span> <span class="operator">*</span>horizontalLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qhboxlayout.html">QHBoxLayout</a></span>(<span class="keyword">this</span>);
          <span class="type"><a href="qgroupbox.html">QGroupBox</a></span> <span class="operator">*</span>groupBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(<span class="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span><span class="operator">::</span>applicationDisplayName()<span class="operator">,</span> <span class="keyword">this</span>);
          horizontalLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupBox);
          verticalLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>(groupBox);
      } <span class="keyword">else</span> {
          verticalLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>(<span class="keyword">this</span>);
      }

      <span class="type"><a href="qtoolbox.html">QToolBox</a></span> <span class="operator">*</span>toolbox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtoolbox.html">QToolBox</a></span>;
      verticalLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(toolbox);

      errorMessageDialog <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qerrormessage.html">QErrorMessage</a></span>(<span class="keyword">this</span>);

      <span class="type">int</span> frameStyle <span class="operator">=</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel;

      integerLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      integerLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>integerButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QInputDialog::get&amp;Int()&quot;</span>));

      doubleLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      doubleLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>doubleButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QInputDialog::get&amp;Double()&quot;</span>));

      itemLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      itemLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>itemButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QInputDialog::getIte&amp;m()&quot;</span>));

      textLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      textLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>textButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QInputDialog::get&amp;Text()&quot;</span>));

      multiLineTextLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      multiLineTextLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>multiLineTextButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QInputDialog::get&amp;MultiLineText()&quot;</span>));

      colorLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      colorLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>colorButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QColorDialog::get&amp;Color()&quot;</span>));

      fontLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      fontLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>fontButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QFontDialog::get&amp;Font()&quot;</span>));

      directoryLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      directoryLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>directoryButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QFileDialog::getE&amp;xistingDirectory()&quot;</span>));

      openFileNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      openFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>openFileNameButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QFileDialog::get&amp;OpenFileName()&quot;</span>));

      openFileNamesLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      openFileNamesLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>openFileNamesButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QFileDialog::&amp;getOpenFileNames()&quot;</span>));

      saveFileNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      saveFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>saveFileNameButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QFileDialog::get&amp;SaveFileName()&quot;</span>));

      criticalLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      criticalLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>criticalButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QMessageBox::critica&amp;l()&quot;</span>));

      informationLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      informationLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>informationButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QMessageBox::i&amp;nformation()&quot;</span>));

      questionLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      questionLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>questionButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QMessageBox::&amp;question()&quot;</span>));

      warningLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      warningLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>warningButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QMessageBox::&amp;warning()&quot;</span>));

      errorLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      errorLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(frameStyle);
      <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>errorButton <span class="operator">=</span>
              <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(tr(<span class="string">&quot;QErrorMessage::showM&amp;essage()&quot;</span>));

      connect(integerButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setInteger);
      connect(doubleButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setDouble);
      connect(itemButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setItem);
      connect(textButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setText);
      connect(multiLineTextButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setMultiLineText);
      connect(colorButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setColor);
      connect(fontButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setFont);
      connect(directoryButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setExistingDirectory);
      connect(openFileNameButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setOpenFileName);
      connect(openFileNamesButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setOpenFileNames);
      connect(saveFileNameButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>setSaveFileName);
      connect(criticalButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>criticalMessage);
      connect(informationButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>informationMessage);
      connect(questionButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>questionMessage);
      connect(warningButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>warningMessage);
      connect(errorButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>Dialog<span class="operator">::</span>errorMessage);

      <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>page <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>(page);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnStretch(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnMinimumWidth(<span class="number">1</span><span class="operator">,</span> <span class="number">250</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(integerButton<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(integerLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(doubleButton<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(doubleLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(itemButton<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(itemLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(textButton<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(textLabel<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(multiLineTextButton<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(multiLineTextLabel<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding)<span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="number">0</span>);
      toolbox<span class="operator">-</span><span class="operator">&gt;</span>addItem(page<span class="operator">,</span> tr(<span class="string">&quot;Input Dialogs&quot;</span>));

      <span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> doNotUseNativeDialog <span class="operator">=</span> tr(<span class="string">&quot;Do not use native dialog&quot;</span>);

      page <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
      layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>(page);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnStretch(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(colorButton<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(colorLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      colorDialogOptionsWidget <span class="operator">=</span> <span class="keyword">new</span> DialogOptionsWidget;
      colorDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(doNotUseNativeDialog<span class="operator">,</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>DontUseNativeDialog);
      colorDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show alpha channel&quot;</span>) <span class="operator">,</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>ShowAlphaChannel);
      colorDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;No buttons&quot;</span>) <span class="operator">,</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>NoButtons);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding)<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(colorDialogOptionsWidget<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span> <span class="operator">,</span><span class="number">2</span>);

      toolbox<span class="operator">-</span><span class="operator">&gt;</span>addItem(page<span class="operator">,</span> tr(<span class="string">&quot;Color Dialog&quot;</span>));

      page <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
      layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>(page);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnStretch(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fontButton<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fontLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      fontDialogOptionsWidget <span class="operator">=</span> <span class="keyword">new</span> DialogOptionsWidget;
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(doNotUseNativeDialog<span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>DontUseNativeDialog);
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show scalable fonts&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>ScalableFonts);
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show non scalable fonts&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>NonScalableFonts);
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show monospaced fonts&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>MonospacedFonts);
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show proportional fonts&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>ProportionalFonts);
      fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;No buttons&quot;</span>) <span class="operator">,</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>NoButtons);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding)<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fontDialogOptionsWidget<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span> <span class="operator">,</span><span class="number">2</span>);
      toolbox<span class="operator">-</span><span class="operator">&gt;</span>addItem(page<span class="operator">,</span> tr(<span class="string">&quot;Font Dialog&quot;</span>));

      page <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
      layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>(page);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnStretch(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(directoryButton<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(directoryLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(openFileNameButton<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(openFileNameLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(openFileNamesButton<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(openFileNamesLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(saveFileNameButton<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(saveFileNameLabel<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span>);
      fileDialogOptionsWidget <span class="operator">=</span> <span class="keyword">new</span> DialogOptionsWidget;
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(doNotUseNativeDialog<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontUseNativeDialog);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Show directories only&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>ShowDirsOnly);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Do not resolve symlinks&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontResolveSymlinks);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Do not confirm overwrite&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontConfirmOverwrite);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Do not use sheet&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontUseSheet);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Readonly&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>ReadOnly);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Hide name filter details&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>HideNameFilterDetails);
      fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>addCheckBox(tr(<span class="string">&quot;Do not use custom directory icons (Windows)&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontUseCustomDirectoryIcons);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding)<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fileDialogOptionsWidget<span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span> <span class="operator">,</span><span class="number">2</span>);
      toolbox<span class="operator">-</span><span class="operator">&gt;</span>addItem(page<span class="operator">,</span> tr(<span class="string">&quot;File Dialogs&quot;</span>));

      page <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
      layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>(page);
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnStretch(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(criticalButton<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(criticalLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(informationButton<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(informationLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(questionButton<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(questionLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(warningButton<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(warningLabel<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(errorButton<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(errorLabel<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="keyword">new</span> <span class="type"><a href="qspaceritem.html">QSpacerItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Ignored<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>MinimumExpanding)<span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="number">0</span>);
      toolbox<span class="operator">-</span><span class="operator">&gt;</span>addItem(page<span class="operator">,</span> tr(<span class="string">&quot;Message Boxes&quot;</span>));

      setWindowTitle(<span class="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span><span class="operator">::</span>applicationDisplayName());
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setInteger()
  {
      bool ok;
      <span class="type">int</span> i <span class="operator">=</span> <span class="type"><a href="qinputdialog.html">QInputDialog</a></span><span class="operator">::</span>getInt(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QInputDialog::getInteger()&quot;</span>)<span class="operator">,</span>
                                   tr(<span class="string">&quot;Percentage:&quot;</span>)<span class="operator">,</span> <span class="number">25</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="operator">&amp;</span>ok);
      <span class="keyword">if</span> (ok)
          integerLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;%1%&quot;</span>)<span class="operator">.</span>arg(i));
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setDouble()
  {
      bool ok;
      <span class="type">double</span> d <span class="operator">=</span> <span class="type"><a href="qinputdialog.html">QInputDialog</a></span><span class="operator">::</span>getDouble(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QInputDialog::getDouble()&quot;</span>)<span class="operator">,</span>
                                         tr(<span class="string">&quot;Amount:&quot;</span>)<span class="operator">,</span> <span class="number">37.56</span><span class="operator">,</span> <span class="operator">-</span><span class="number">10000</span><span class="operator">,</span> <span class="number">10000</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="operator">&amp;</span>ok);
      <span class="keyword">if</span> (ok)
          doubleLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="type"><a href="../qtcore/qstring.html">QString</a></span>(<span class="string">&quot;$%1&quot;</span>)<span class="operator">.</span>arg(d));
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setItem()
  {
      <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> items;
      items <span class="operator">&lt;</span><span class="operator">&lt;</span> tr(<span class="string">&quot;Spring&quot;</span>) <span class="operator">&lt;</span><span class="operator">&lt;</span> tr(<span class="string">&quot;Summer&quot;</span>) <span class="operator">&lt;</span><span class="operator">&lt;</span> tr(<span class="string">&quot;Fall&quot;</span>) <span class="operator">&lt;</span><span class="operator">&lt;</span> tr(<span class="string">&quot;Winter&quot;</span>);

      bool ok;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> item <span class="operator">=</span> <span class="type"><a href="qinputdialog.html">QInputDialog</a></span><span class="operator">::</span>getItem(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QInputDialog::getItem()&quot;</span>)<span class="operator">,</span>
                                           tr(<span class="string">&quot;Season:&quot;</span>)<span class="operator">,</span> items<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="keyword">false</span><span class="operator">,</span> <span class="operator">&amp;</span>ok);
      <span class="keyword">if</span> (ok <span class="operator">&amp;</span><span class="operator">&amp;</span> <span class="operator">!</span>item<span class="operator">.</span>isEmpty())
          itemLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(item);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setText()
  {
      bool ok;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> text <span class="operator">=</span> <span class="type"><a href="qinputdialog.html">QInputDialog</a></span><span class="operator">::</span>getText(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QInputDialog::getText()&quot;</span>)<span class="operator">,</span>
                                           tr(<span class="string">&quot;User name:&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span><span class="operator">::</span>Normal<span class="operator">,</span>
                                           <span class="type"><a href="../qtcore/qdir.html">QDir</a></span><span class="operator">::</span>home()<span class="operator">.</span>dirName()<span class="operator">,</span> <span class="operator">&amp;</span>ok);
      <span class="keyword">if</span> (ok <span class="operator">&amp;</span><span class="operator">&amp;</span> <span class="operator">!</span>text<span class="operator">.</span>isEmpty())
          textLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(text);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setMultiLineText()
  {
      bool ok;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> text <span class="operator">=</span> <span class="type"><a href="qinputdialog.html">QInputDialog</a></span><span class="operator">::</span>getMultiLineText(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QInputDialog::getMultiLineText()&quot;</span>)<span class="operator">,</span>
                                                    tr(<span class="string">&quot;Address:&quot;</span>)<span class="operator">,</span> <span class="string">&quot;John Doe\nFreedom Street&quot;</span><span class="operator">,</span> <span class="operator">&amp;</span>ok);
      <span class="keyword">if</span> (ok <span class="operator">&amp;</span><span class="operator">&amp;</span> <span class="operator">!</span>text<span class="operator">.</span>isEmpty())
          multiLineTextLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(text);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setColor()
  {
      <span class="keyword">const</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>ColorDialogOptions options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(colorDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      <span class="keyword">const</span> <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color <span class="operator">=</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>getColor(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>green<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="string">&quot;Select Color&quot;</span><span class="operator">,</span> options);

      <span class="keyword">if</span> (color<span class="operator">.</span>isValid()) {
          colorLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(color<span class="operator">.</span>name());
          colorLabel<span class="operator">-</span><span class="operator">&gt;</span>setPalette(<span class="type"><a href="../qtgui/qpalette.html">QPalette</a></span>(color));
          colorLabel<span class="operator">-</span><span class="operator">&gt;</span>setAutoFillBackground(<span class="keyword">true</span>);
      }
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setFont()
  {
      <span class="keyword">const</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>FontDialogOptions options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(fontDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      bool ok;
      <span class="type"><a href="../qtgui/qfont.html">QFont</a></span> font <span class="operator">=</span> <span class="type"><a href="qfontdialog.html">QFontDialog</a></span><span class="operator">::</span>getFont(<span class="operator">&amp;</span>ok<span class="operator">,</span> <span class="type"><a href="../qtgui/qfont.html">QFont</a></span>(fontLabel<span class="operator">-</span><span class="operator">&gt;</span>text())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="string">&quot;Select Font&quot;</span><span class="operator">,</span> options);
      <span class="keyword">if</span> (ok) {
          fontLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(font<span class="operator">.</span>key());
          fontLabel<span class="operator">-</span><span class="operator">&gt;</span>setFont(font);
      }
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setExistingDirectory()
  {
      <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>Options options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      options <span class="operator">|</span><span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>DontResolveSymlinks <span class="operator">|</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>ShowDirsOnly;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> directory <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getExistingDirectory(<span class="keyword">this</span><span class="operator">,</span>
                                  tr(<span class="string">&quot;QFileDialog::getExistingDirectory()&quot;</span>)<span class="operator">,</span>
                                  directoryLabel<span class="operator">-</span><span class="operator">&gt;</span>text()<span class="operator">,</span>
                                  options);
      <span class="keyword">if</span> (<span class="operator">!</span>directory<span class="operator">.</span>isEmpty())
          directoryLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(directory);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setOpenFileName()
  {
      <span class="keyword">const</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>Options options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> selectedFilter;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getOpenFileName(<span class="keyword">this</span><span class="operator">,</span>
                                  tr(<span class="string">&quot;QFileDialog::getOpenFileName()&quot;</span>)<span class="operator">,</span>
                                  openFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>text()<span class="operator">,</span>
                                  tr(<span class="string">&quot;All Files (*);;Text Files (*.txt)&quot;</span>)<span class="operator">,</span>
                                  <span class="operator">&amp;</span>selectedFilter<span class="operator">,</span>
                                  options);
      <span class="keyword">if</span> (<span class="operator">!</span>fileName<span class="operator">.</span>isEmpty())
          openFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(fileName);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setOpenFileNames()
  {
      <span class="keyword">const</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>Options options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> selectedFilter;
      <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> files <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getOpenFileNames(
                                  <span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QFileDialog::getOpenFileNames()&quot;</span>)<span class="operator">,</span>
                                  openFilesPath<span class="operator">,</span>
                                  tr(<span class="string">&quot;All Files (*);;Text Files (*.txt)&quot;</span>)<span class="operator">,</span>
                                  <span class="operator">&amp;</span>selectedFilter<span class="operator">,</span>
                                  options);
      <span class="keyword">if</span> (files<span class="operator">.</span>count()) {
          openFilesPath <span class="operator">=</span> files<span class="operator">[</span><span class="number">0</span><span class="operator">]</span>;
          openFileNamesLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="type"><a href="../qtcore/qstring.html">QString</a></span>(<span class="string">&quot;[%1]&quot;</span>)<span class="operator">.</span>arg(files<span class="operator">.</span>join(<span class="string">&quot;, &quot;</span>)));
      }
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>setSaveFileName()
  {
      <span class="keyword">const</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>Options options <span class="operator">=</span> <span class="type"><a href="../qtcore/qflag.html">QFlag</a></span>(fileDialogOptionsWidget<span class="operator">-</span><span class="operator">&gt;</span>value());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> selectedFilter;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getSaveFileName(<span class="keyword">this</span><span class="operator">,</span>
                                  tr(<span class="string">&quot;QFileDialog::getSaveFileName()&quot;</span>)<span class="operator">,</span>
                                  saveFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>text()<span class="operator">,</span>
                                  tr(<span class="string">&quot;All Files (*);;Text Files (*.txt)&quot;</span>)<span class="operator">,</span>
                                  <span class="operator">&amp;</span>selectedFilter<span class="operator">,</span>
                                  options);
      <span class="keyword">if</span> (<span class="operator">!</span>fileName<span class="operator">.</span>isEmpty())
          saveFileNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(fileName);
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>criticalMessage()
  {
      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>StandardButton reply;
      reply <span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>critical(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QMessageBox::critical()&quot;</span>)<span class="operator">,</span>
                                      MESSAGE<span class="operator">,</span>
                                      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Abort <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Retry <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Ignore);
      <span class="keyword">if</span> (reply <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Abort)
          criticalLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Abort&quot;</span>));
      <span class="keyword">else</span> <span class="keyword">if</span> (reply <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Retry)
          criticalLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Retry&quot;</span>));
      <span class="keyword">else</span>
          criticalLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Ignore&quot;</span>));
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>informationMessage()
  {
      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>StandardButton reply;
      reply <span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>information(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QMessageBox::information()&quot;</span>)<span class="operator">,</span> MESSAGE);
      <span class="keyword">if</span> (reply <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Ok)
          informationLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;OK&quot;</span>));
      <span class="keyword">else</span>
          informationLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Escape&quot;</span>));
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>questionMessage()
  {
      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>StandardButton reply;
      reply <span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>question(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;QMessageBox::question()&quot;</span>)<span class="operator">,</span>
                                      MESSAGE<span class="operator">,</span>
                                      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Yes <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>No <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Cancel);
      <span class="keyword">if</span> (reply <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Yes)
          questionLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Yes&quot;</span>));
      <span class="keyword">else</span> <span class="keyword">if</span> (reply <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>No)
          questionLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;No&quot;</span>));
      <span class="keyword">else</span>
          questionLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Cancel&quot;</span>));
  }

  <span class="type">void</span> Dialog<span class="operator">::</span>warningMessage()
  {
      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span> msgBox(<span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Warning<span class="operator">,</span> tr(<span class="string">&quot;QMessageBox::warning()&quot;</span>)<span class="operator">,</span>
                         MESSAGE<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="keyword">this</span>);
      msgBox<span class="operator">.</span>setDetailedText(MESSAGE_DETAILS);
      msgBox<span class="operator">.</span>addButton(tr(<span class="string">&quot;Save &amp;Again&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>AcceptRole);
      msgBox<span class="operator">.</span>addButton(tr(<span class="string">&quot;&amp;Continue&quot;</span>)<span class="operator">,</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>RejectRole);
      <span class="keyword">if</span> (msgBox<span class="operator">.</span>exec() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>AcceptRole)
          warningLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Save Again&quot;</span>));
      <span class="keyword">else</span>
          warningLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Continue&quot;</span>));

  }

  <span class="type">void</span> Dialog<span class="operator">::</span>errorMessage()
  {
      errorMessageDialog<span class="operator">-</span><span class="operator">&gt;</span>showMessage(
              tr(<span class="string">&quot;This dialog shows and remembers error messages. &quot;</span>
                 <span class="string">&quot;If the checkbox is checked (as it is by default), &quot;</span>
                 <span class="string">&quot;the shown message will be shown again, &quot;</span>
                 <span class="string">&quot;but if the user unchecks the box the message &quot;</span>
                 <span class="string">&quot;will not appear again if QErrorMessage::showMessage() &quot;</span>
                 <span class="string">&quot;is called with the same message.&quot;</span>));
      errorLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;If the box is unchecked, the message &quot;</span>
                             <span class="string">&quot;won't appear again.&quot;</span>));
  }

</pre>
</div>
<!-- @@@dialogs/standarddialogs/dialog.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
